package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Train;
import com.api.shopapi.entity.dto.ArticleDTO;
import com.api.shopapi.mapper.TrainMapper;
import com.api.shopapi.service.TrainService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("TrainServiceImplOne")
public class TrainServiceImplOne implements TrainService {

    @Autowired
    private TrainMapper trainMapper;

    @Override
    public
    int insert(Train train){
        return trainMapper.insert(train);
    }

    @Override
    public
    int update(Train train){
        return trainMapper.update(train);
    }

    @Override
    public
    Train getByTrainCode(String trainCode){
        return trainMapper.getByTrainCode(trainCode);
    }

    @Override
    public
    PageInfo<Train> getPageList(int pageIndex, int pageSize, String governmentCode, String title,
                                int status, String startTime, String endTime){
        PageHelper.startPage(pageIndex,pageSize);
        List<Train> articleList =trainMapper.getPageList(governmentCode,title,status,startTime,endTime);
        return new PageInfo<>(articleList);
    }


    @Override
    public
    PageInfo<Train> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex,pageSize);
        List<Train> articleList =trainMapper.listByGovCode(governmentCode);
        return new PageInfo<>(articleList);
    }

}
